package com.heima.behavior.controller;


import com.heima.behavior.service.*;
import com.heima.model.behavior.dtos.*;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "行为服务",value = "行为服务列表接口")
@RestController
@RequestMapping("/api/v1")
public class LikesBehaviorController {

    /**
     * 1.点赞行为
     * 测试通过
     */
    @Autowired
    private ApLikesBehaviorService apLikesBehaviorService;

    @PostMapping("/likes_behavior")
    public ResponseResult load(@RequestBody LikesBehaviorDTO dto) {
       return apLikesBehaviorService.like(dto);
    }

    /**
     * 2.保存阅读
     * 测试通过
     */
    @Autowired
    ApReadBehaviorService apReadBehaviorService;
    @PostMapping("/read_behavior")
    public ResponseResult read(@RequestBody ReadBehaviorDTO dto) {
        return apReadBehaviorService.readBehavior(dto);
    }

    /**
     *3.不喜欢行为
     * 测试通过
     */
    @Autowired
    ApUnlikeBehaviorService apUnlikeBehaviorService;
    @PostMapping("/un_likes_behavior")
    public ResponseResult unLikes(@RequestBody UnLikesBehaviorDTO dto) {
        return apUnlikeBehaviorService.unlikeBehavior(dto);
    }

    /**
     * 4.收藏行为
     * 测试通过
     */
    @Autowired
    ApCollectionBehaviorService apCollectionBehaviorService;
    @PostMapping("/collection_behavior")
    public ResponseResult collection(@RequestBody CollectionBehaviorDTO dto) {
        return apCollectionBehaviorService.collectBehavior(dto);
    }


    /**
     * 5.文章行为
     * 测试通过
     *
     */
     @Autowired
    ApArticleBehaviorService  apArticleBehaviorService;
    @PostMapping("/article/load_article_behavior")
    public ResponseResult article(@RequestBody ArticleBehaviorDTO dto) {
        return apArticleBehaviorService.loadArticleBehavior(dto);
    }


}

